package com.project.controller;

import com.project.bean.StudentBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("test")
public class TestController {

    @RequestMapping("show")
    public String show(HttpServletRequest request){
        //在request中绑定共享对象，作用范围为一次请求范围内
        request.setAttribute("name","tom");
        request.setAttribute("student",
                new StudentBean(10,"张无忌",96));
        List<StudentBean> list = List.of(new StudentBean(10,"张无忌",96),
                new StudentBean(12,"周芷若",58),
                new StudentBean(15,"赵敏",76),
                new StudentBean(18,"小昭",85));
        request.setAttribute("list",list);
        return "/html/index.html";
    }
}
